package com.jzy.bxb.model.mongo.dao;

import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.dao.BasicDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.jzy.bxb.core.db.mongo.AbsMongoManager;
import com.jzy.bxb.model.mongo.entity.Suggest;

/**
 * 建议
 *
 * @author JiangZhiYong
 * @date 2017-07-04 QQ:359135103
 */
@Repository
public class SuggestDao extends BasicDAO<Suggest, String> {
	private static volatile SuggestDao suggestDao;

	@Autowired
	public SuggestDao(Datastore ds) {
		super(ds);
	}

	public SuggestDao(AbsMongoManager mongoManager) {
		super(Suggest.class, mongoManager.getMongoClient(), mongoManager.getMorphia(),
				mongoManager.getMongoConfig().getDbName());
	}

	public static SuggestDao init(AbsMongoManager mongoManager) {
		if (suggestDao == null) {
			synchronized (UserDao.class) {
				if (suggestDao == null) {
					suggestDao = new SuggestDao(mongoManager);
				}
			}
		}
		return suggestDao;
	}

	/**
	 * 
	 * @param suggest
	 */
	public static void saveSuggest(Suggest suggest) {
		suggestDao.save(suggest);
	}
	
	
}
